<template>
  <div
      :class="['common-icon-button-wrap',status && 'common-icon-button__check',disabled && 'common-icon-button__disabled']"
      @click="statusChange"
  >
    <div class="common-icon-button__icon">
      <i :class="['iconfont',icon]"></i>
    </div>
    <div class="common-icon-button__content">{{ content }}</div>
  </div>
</template>

<script>
export default {
  name: 'IconButton',
  props: {
    icon: {
      type: String,
      default: 'icon-merge'
    },// iconfont 名称
    disabled: {
      type: Boolean,
      default: false
    },// 禁用状态
    content: {
      type: String,
      default: '按钮'
    },
    status: {
      type: Boolean,
      default: false
    }// 选中状态
  },
  data() {
    return {}
  },
  methods: {
    statusChange() {
      if (!this.disabled) this.$emit('change', !this.status)
    }
  }
}
</script>

<style scoped lang="scss">
.common-icon-button-wrap {
  height: 24px;
  box-sizing: border-box;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 4px;
  color: #303133;
  user-select: none;

  .common-icon-button__icon {
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;

    i {
      font-size: 14px;
    }
  }

  .common-icon-button__content {
    font-size: 14px;
    margin-left: 4px;
  }
}

.common-icon-button__check {
  background-color: #eeeeee;
}

.common-icon-button__disabled {
  color: #aaa!important;
  cursor: not-allowed!important;
}
</style>
